package com.mobi.cacti;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;

@SuppressWarnings("deprecation")
public class MainActivity extends TabActivity {

	public static Button btnBack, btnRecent, btnHistory;
	public static String lastChildName;
	public static LinearLayout ll_child;
	public static LinearLayout ll_recent;
	
	 public interface setOnClickListener {
        public void onClickBlack(Activity activity);   
    }    
	 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		/*
		setContentView(R.layout.atv_main);
		
		btnBack = (Button)findViewById(R.id.btnBack);		
		btnRecent = (Button)findViewById(R.id.btnRecent);
		btnHistory = (Button)findViewById(R.id.btnHistory);		
		ll_recent = (LinearLayout)findViewById(R.id.ll_recent);
		*/
		Intent intent;
		final TabHost tabHost = getTabHost(); 
		
		intent = new Intent().setClass(this, MainInfoActivity.class);
		TabSpec tab = tabHost.newTabSpec("").setIndicator("", null).setContent(intent);
		tabHost.addTab(tab);
		
		intent = new Intent().setClass(this, GraphActivity.class);
		tab = tabHost.newTabSpec("").setIndicator("", null).setContent(intent);
		tabHost.addTab(tab);
		
		intent = new Intent().setClass(this, NewsActivity.class);
		tab = tabHost.newTabSpec("").setIndicator("", null).setContent(intent);
		tabHost.addTab(tab);
				
		setTabBGDefault(tabHost);				
		tabHost.setOnTabChangedListener(new OnTabChangeListener() {
			@Override
			public void onTabChanged(String arg0) {
				MainActivity.ll_recent.setVisibility(View.GONE);
				MainActivity.btnBack.setVisibility(View.GONE);
				setTabBG(tabHost);				
			}
		});
		
	}//end onCreate
	
	public void setTabBG(TabHost tabhost) {
		/*
		if(tabhost.getCurrentTab() == 0){			
			tabhost.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.cus_info_b);
			tabhost.getTabWidget().getChildAt(1).setBackgroundResource(R.drawable.graph);
			tabhost.getTabWidget().getChildAt(2).setBackgroundResource(R.drawable.news);
		}else if(tabhost.getCurrentTab() == 1){
			tabhost.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.cus_info);
			tabhost.getTabWidget().getChildAt(1).setBackgroundResource(R.drawable.graph_b);
			tabhost.getTabWidget().getChildAt(2).setBackgroundResource(R.drawable.news); 
		}else if(tabhost.getCurrentTab() == 2){
			tabhost.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.cus_info);
			tabhost.getTabWidget().getChildAt(1).setBackgroundResource(R.drawable.graph);
			tabhost.getTabWidget().getChildAt(2).setBackgroundResource(R.drawable.news_b);
		}
		*/
	}
	public void setTabBGDefault(TabHost tabhost) {
		/*
		tabhost.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.cus_info_b);
		tabhost.getTabWidget().getChildAt(1).setBackgroundResource(R.drawable.graph);
		tabhost.getTabWidget().getChildAt(2).setBackgroundResource(R.drawable.news);
		*/
	}

}